﻿
Partial Class admin_finance
    Inherits Page

    Dim _context As TaxiEntities

    Function GetContext() As TaxiEntities

        If IsNothing(HttpContext.Current.Application("_context")) = True Then

            HttpContext.Current.Application("_context") = New TaxiEntities

        End If
        _context = HttpContext.Current.Application("_context")
        Return HttpContext.Current.Application("_context")

    End Function
    Protected Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click

        Dim phone As String = transfer_number.Text

        Dim money As Double = Val(transfer_money.Text)

        GetContext()

        Dim tr As New transfers

        tr.transfer_code = "Администратор"

        tr.transfer_amount = money

        tr.client_id = _context.taxist.FirstOrDefault(Function(x) x.taxi_phone = phone).taxi_id

        tr.transfer_id = Guid.NewGuid

        tr.transfer_date = Now.AddHours(2)

        tr.txt_id = ""

        _context.transfers.Add(tr)

        _context.SaveChanges()

        SqlDataSource1.DataBind()

        GridView1.DataBind()

        transfer_money.Text = ""

        transfer_number.Text = ""

    End Sub
End Class
